package jp.co.systemi.asp.workflow;

import java.util.logging.Logger;

import jp.co.systemi.asp.workflow.group.GroupReg;

import org.apache.wicket.Page;
import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.PageExpiredException;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebRequestCycle;

public class WorkflowRequestCycle extends WebRequestCycle {
    private static final Logger log = Logger
        .getLogger(GroupReg.class.getName());
    @Override
    public Page onRuntimeException(Page page, RuntimeException e) {
        log.info(e.getLocalizedMessage());
        for(StackTraceElement msg : e.getStackTrace()){
            log.info(msg.getClassName() + ":" + msg.getMethodName() + ":" + msg.getLineNumber());
        }
        e.printStackTrace();
        if (e instanceof PageExpiredException) {
            return new Expire();
        }
        return new ErrorPage(e);
    }

    @Override
    protected void onBeginRequest() {
        super.onBeginRequest();
//        UserService userService = UserServiceFactory
//            .getUserService();
//
//        com.google.appengine.api.users.User usr = userService
//            .getCurrentUser();
//        log.info("usr is " + usr.getEmail());
    }

    public WorkflowRequestCycle(WebApplication application, WebRequest request, Response response) {
        super(application, request, response);
    }
}
